package com.bilibili.controller;

import com.bilibili.entity.PicCategory;
import com.bilibili.entity.PicRegion;
import com.bilibili.service.PicCategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 题材国家分类的Controller
 * @Author Sandy
 */
@RestController
@RequestMapping("pic_category")
public class PicCategoryController {
    @Autowired
    private PicCategoryService picCategoryService;

    /**
     *
     * @param categoryId 题材
     * @return 题材的实体类
     */
//    @RequestMapping(value = "getCategoryById", method = RequestMethod.GET, params = {"categoryId"})
    @RequestMapping(value = "{categoryId}", method = RequestMethod.GET)
    public PicCategory getCategoryById(@PathVariable("categoryId") Integer categoryId) {
        return picCategoryService.getCategoryById(categoryId);
    }

    /**
     * @return 拿到所有漫画的分类
     */
//    @RequestMapping(value = "category", method = RequestMethod.GET )
    @RequestMapping(method = RequestMethod.GET , params = {"fetch_type=category"} )
    public List<PicCategory> getCartoonsCategory() {
        return picCategoryService.getAllCategory();
    }

    /**
     * @return 拿到所有的漫画国家分类
     */
//    @RequestMapping(value = "region", method = RequestMethod.GET )
    @RequestMapping(method = RequestMethod.GET , params = {"fetch_type=region"})
    public List<PicRegion> getRegion() {
        return picCategoryService.getAllRegion();
    }
}
